import java.util.ArrayList;
import java.util.List;

class Solution {
    public List<Integer> numberOfAlternatingGroups(int[] colors, int[][] queries) {
        int n=queries.length;
        List<Integer> res=new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if(queries[i][0]==1){
                res.add(numberOfAlternatingGroups(colors,queries[i][1]));
            }else{
                colors[queries[i][1]]=queries[i][2];
            }
        }
        return res;
    }
    public int numberOfAlternatingGroups(int[] colors, int k) {
        int n=colors.length;
        int ans=0;
        int count=0;

        for (int i = 0; i < 2*n; i++) {
            if(i>0 && colors[i%n]==colors[(i-1)%n]){
                count=1;
            }else{
                count++;
            }
            if(i>=n && count>=k){
                ans++;
            }
        }

        return ans;
    }
}